package com.yanq.liancar.adapter;

import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yanq.liancar.R;
import com.yanq.liancar.bean.ServiceTypeBean;
import com.yanq.liancar.util.LogUtils;

import java.util.List;

public class ShopServiceAdapter extends BaseAdapter {
    private Context context;
    public List<String> datas;
    private LayoutInflater layoutInflater;

    public ShopServiceAdapter(Context context, List<String> list) {
        LogUtils.e("22222", list.size() + "");
        this.context = context;

        this.datas = list;

        layoutInflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Log.e("dasdadasda", "asdadada" + "++++++++" + datas.size());
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = layoutInflater.inflate(R.layout.item_shopservice, parent, false);
            holder.textView = convertView.findViewById(R.id.tv_shopservice);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.textView.setText(datas.get(position));

        return convertView;
    }

    static class ViewHolder {
        TextView textView;
    }

    public void setData(List<String> list) {
        this.datas = list;
        notifyDataSetChanged();
        Log.e("dasdadasda", "asdadada" + "=========" + list.size());

    }
}
